﻿using System;

namespace RStudio.Elevator
{
    /// <summary>
    /// 电梯事件触发器
    /// </summary>
    public class ElevatorEvent
    {
        /// <summary>
        /// 事件|开始运动
        /// </summary>
        public event Action<DataFloor> OnElevatorActived;

        /// <summary>
        /// 事件|抵达楼层
        /// </summary>
        public event Action<DataFloor> OnElevatorArrived;

        /// <summary>
        /// 事件|故障发生
        /// </summary>
        public event Action OnElevatorDamaged;

        /// <summary>
        /// 事件|恢复正常
        /// </summary>
        public event Action OnElevatorRecovered;

        /// <summary>
        /// 事件|状态变更
        /// </summary>
        public event Action<ElevatorStateType> OnElevatorStatusChanged;




        /// <summary>
        /// 事件|门状态更新
        /// </summary>
        public event Action<bool> OnDoorStateChanged;

        public event Action OnDoorOpening;

        public event Action OnDoorOpened;

        public event Action OnDoorClosing;

        public event Action OnDoorClosed;





        public void TriggerFloorArrived(DataFloor data) => OnElevatorArrived?.Invoke(data);
        public void TriggerStateChanged(ElevatorStateType state) => OnElevatorStatusChanged?.Invoke(state);
        public void TriggerDoorStateChanged(bool isOpened) => OnDoorStateChanged?.Invoke(isOpened);
        public void TriggerDamaged() => OnElevatorDamaged?.Invoke();
        public void TriggerRecovered() => OnElevatorRecovered?.Invoke();
    }
}
